home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / xulrunner / python / theme.py < prev    next >
Encoding:
Python Source  |  2007-11-12  |  3.3 KB  |  82 lines

  1. # Miro - an RSS based video player application
  2. # Copyright (C) 2007 Participatory Culture Foundation
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. import config
  19. import prefs
  20. import app
  21. import views
  22. import indexes
  23. import os
  24. from eventloop import asUrgent
  25. from database import DDBObject
  26. import opml
  27. import iconcache
  28. import guide
  29.  
  30. class ThemeHistory(DDBObject):
  31.     def __init__(self):
  32.         DDBObject.__init__(self)
  33.         self.lastTheme = None
  34.         self.pastThemes = []
  35.         self.theme = unicode(config.get(prefs.THEME_NAME))
  36.         if self.theme is not None:
  37.             self.pastThemes.append(self.theme)
  38.             self.onFirstRun()
  39.  
  40.     def onRestore(self):
  41.         self.theme = unicode(config.get(prefs.THEME_NAME))
  42.         if not (self.theme is None or self.theme in self.pastThemes):
  43.             self.pastThemes.append(self.theme)
  44.             self.onFirstRun()
  45.         if self.lastTheme != self.theme:
  46.             self.onThemeChange()
  47.             self.lastTheme = self.theme
  48.  
  49.     @asUrgent
  50.     def onThemeChange(self):
  51.         if len(views.default_guide) > 0:
  52.             views.default_guide[0].title = None
  53.             views.default_guide[0].favicon = None
  54.             views.default_guide[0].updated_url = None
  55.             views.default_guide[0].iconCache.remove()
  56.             views.default_guide[0].iconCache= iconcache.IconCache (views.default_guide[0], is_vital = True)
  57.             views.default_guide[0].signalChange()
  58.         self.signalChange()
  59.         
  60.  
  61.     # This should be run once for each theme
  62.     @asUrgent
  63.     def onFirstRun(self):
  64.         # Clear out the channel guide icon
  65.         if config.get(prefs.MAXIMIZE_ON_FIRST_RUN).lower() not in ['false','no','0']:
  66.             app.delegate.maximizeWindow()
  67.         # FIXME -- this needs to be here and in app.py. We should
  68.         #          unify the code --NN
  69.         if ((config.get(prefs.DEFAULT_CHANNELS_FILE) is not None) and
  70.             (config.get(prefs.THEME_NAME) is not None) and 
  71.             (config.get(prefs.THEME_DIRECTORY) is not None)):
  72.             importer = opml.Importer()
  73.             filepath = os.path.join(
  74.                 config.get(prefs.THEME_DIRECTORY),
  75.                 config.get(prefs.THEME_NAME),
  76.                 config.get(prefs.DEFAULT_CHANNELS_FILE))
  77.             importer.importSubscriptionsFrom(filepath,
  78.                                              showSummary = False)
  79.         for temp_guide in unicode(config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split():
  80.             if views.guides.getItemWithIndex(indexes.guidesByURL, temp_guide) is None:
  81.                 guide.ChannelGuide(temp_guide)
  82.